<template>
	<view class="main">
		<u-navbar back-text="" slot="center" :autoBack="true" safeAreaInsetTop placeholder>
			<view slot="center" class="leftText">{{types == 0?'自我介绍':'工作内容'}}</view>
		</u-navbar>
		<view class="form">
			<u--form
				labelPosition="left"
				:model="model1"
				ref="form1">
				<u--textarea v-model="notice" height="180" maxlength="400"
				placeholder="例如：2018年到2020年在万达项目中，做木工，铝膜，资料现场都可以" 
				count border="none"></u--textarea>
			</u--form>
			
		</view>
		<view class="submit"><u-button type="primary" @click="sendPost()" text="确定" customStyle="background:#0575FF;"></u-button></view>
	</view>
</template>

<script>
import Index from '@/common/index-model.js'
let index=new Index();
let that = null;
export default {
	data() {
		return {
			notice:'',
			myCard:{},
			str:{},//上个页面传过来的值
			types:0,//类型
		}
	},
	components: {

	},
	onLoad(opt) {
		this.getCardDetail();
		if(opt.str){
			this.str = JSON.parse(opt.str)
			// console.log(this.str)
			// this.notice = this.str.contentText
			// console.log(this.notice,'===this.notice==')
		}
		if(opt.type){
			this.types = opt.type
		}
	},
	methods:{
		getCardDetail(){
			index.getPublicUserMember({},'/client/card/detail','get',res=>{
				if(res.data.code == 200 && res.data.success){
					let data=res.data.result;
					if(this.types == 0){
						this.notice=data.notice;
					}
				    if(this.types == 'preadd' || this.types == 'pdnode'){
						this.notice= this.str.contentText
					}
						
					if(this.types == 'pdnodeedit'){
						this.notice= this.str.desc
					}
				}
			})
		},
		sendPost(){
			if(!this.notice){
				index.show_tips('请输入自我介绍信息')
				return
			}
			let mpsends={
				'notice':this.notice
			}
			if(this.types == 0){
				index.getPublicUserMember(mpsends,'/client/card/modify','post',res=>{
					if(res.data.code == 200 && res.data.success){
						index.show_tips('操作成功')
						setTimeout(()=>{
							index.navigate_back(1)
						},500)
					}else{
						index.show_tips(res.data.message);
						return false
					}
				})
			}
			if(this.types == 'preadd'){
				this.str.contentText = this.notice
				let url = '../../pagesC/release/index?str='+JSON.stringify(this.str)
				index.redirectto(url)
			}
			if(this.types == 'pdnode'){
				this.str.contentText = this.notice
				let url = '../../pagesC/perfect/index?str='+JSON.stringify(this.str)
				index.redirectto(url)
			}
			if(this.types == 'pdnodeedit'){
				this.str.desc = this.notice
				let url = '../../pagesC/perfect/editprefect?str='+JSON.stringify(this.str)
				index.redirectto(url)
			}
		},
	}
}	
</script>

<style>
@import url("@/static/css/publics.css");
page{
	background: #F3F3F3;
}
.form{ padding: 20rpx; background: #fff; margin-bottom: 80rpx;}
.submit{ padding: 20rpx;}
/deep/.input-placeholder{ color: #f00;}
</style>